const router = require('koa-router')()

const Mock = require('mockjs')

const { list } = Mock.mock({
  "list|10": [{
    "id": "@id",
    "image": "@image(120x80, @color)",
    "title": "@ctitle"
  }]
})

router.get('/list', ctx => {
  ctx.body = {
    code: 200,
    data: list
  }
})

router.get('/detail/:id', ctx => {
  // 获取id
  const { id } = ctx.params;

  const item = list.find(v => v.id === id)

  ctx.body = {
    data: item,
    code:200
  }

})

module.exports = router
